package com.tgy.kafka.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tgy.kafka.consumer.KafkaConsumer;
import javax.annotation.Resource;

/***
 * @ClassName: MyKafakaController
 * @Description:
 * @Auther: 送你一块二向箔
 * @Date: 9:59 2022/4/7
 * @version : V1.0
 */
@RestController
public class MyKafakaController {

    @Value("${TOPIC_NAME}")
    private String TOPIC_NAME ;
    private final static String CONSUMER_GROUP_NAME = "bbb";
    @Resource
    KafkaTemplate<String, String> kafkaTemplate;

    @RequestMapping("/send/{msg}")
    public String send(@PathVariable String msg){
        kafkaTemplate.send(TOPIC_NAME, 0 ,"test",msg);
        return "success"+msg;
    }

//    @Resource
//    KafkaConsumer kafkaConsumer;
//
//    @RequestMapping("/consumer")
//    public String consumer(){
//        kafkaConsumer.listenGroup1(CONSUMER_GROUP_NAME);
//        return "success";
//    }
}

